package com.neu.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.neu.po.Goods;
import com.neu.po.GoodsType;
import com.neu.po.ResponseResult;
import com.neu.service.GoodsService;

@RestController
@RequestMapping("goods")
public class GoodsController {
	@Autowired
	private GoodsService goodsService;
	
	@RequestMapping("insert")
	public ResponseResult insert(@RequestBody Goods goods) {
		ResponseResult result = new ResponseResult();
		result.setData(goodsService.insert(goods));
		return result;
	}
	
	@RequestMapping("update")
	public ResponseResult update(@RequestBody Goods goods) {
		ResponseResult result = new ResponseResult();
		result.setData(goodsService.update(goods));
		return result;
	}
	
	@RequestMapping("typeDel")
	public ResponseResult typeDel(int id) {
		ResponseResult result = new ResponseResult();
		result.setData(goodsService.typeDel(id));
		return result;
	}
	
	@RequestMapping("getPaged")
	public ResponseResult getPaged(int pageNum,int pageSize,String keyword) {
		ResponseResult result = new ResponseResult();
		result.setData(goodsService.getPaged(pageNum, pageSize, keyword));
		return result;
	}
	
	@RequestMapping("getAll")
	public ResponseResult getAll() {
		ResponseResult result = new ResponseResult();
		result.setData(goodsService.getAll());
		return result;
	}
	
	@RequestMapping("insertType")
	public ResponseResult insertType(@RequestBody GoodsType goodsType) {
		ResponseResult result = new ResponseResult();
		result.setData(goodsService.insertType(goodsType));
		return result;
	}
	
	@RequestMapping("batchDel")
	public ResponseResult batchDel(@RequestBody List<Integer> ids) {
		ResponseResult result = new ResponseResult();
		result.setData(goodsService.batchDel(ids));
		
		return result;
	}
}
